
#### PACKAGES ####

library(tidyverse)
library(lme4)
library(clubSandwich)
library(modelsummary)
library(patchwork)

#### DATA GENERATION ####

conflictmerged <- readRDS("./conflictmerged_impute20.rds") %>%
  distinct(.keep_all = TRUE) 

conflictmerged <- conflictmerged %>%
  mutate(sensitivity = ifelse(ics_number_main %in% c("01", "03"), "Fundamentals and Governance",
                              ifelse(ics_number_main %in% c("07", "17", "19"), "Scientific and Technical Standards",
                                     ifelse(ics_number_main %in% c("21", "23", "27", "29", "31", "33"), "Engineering Disciplines",
                                            ifelse(ics_number_main %in% c("25", "53", "59", "61", "67", "71", "73", "75", "77", "79", "81", "83", "85", "87"), 
                                                   "Manufacturing and Production",
                                                   ifelse(ics_number_main %in% c("43", "45", "47", "49", "91", "93"), "Transportation and Structural Engineering",
                                                          ifelse(ics_number_main %in% c("11"), "Health and Medical Technology",
                                                                 ifelse(ics_number_main %in% c("13"), "Environmental and Safety Standards",
                                                                        ifelse(ics_number_main %in% c("95"), "Military Standards",
                                                                               ifelse(ics_number_main %in% c("97"), "Domestic and Commercial Standards",
                                                                                      ifelse(ics_number_main %in% c("99"), "Other", "Other"))))))))))) %>%
  mutate(sensitivity = factor(sensitivity, levels = c("Other",
                                                      "Scientific and Technical Standards",
                                                      "Engineering Disciplines",
                                                      "Manufacturing and Production",
                                                      "Transportation and Structural Engineering",
                                                      "Health and Medical Technology", 
                                                      "Environmental and Safety Standards",
                                                      "Military Standards",
                                                      "Domestic and Commercial Standards",
                                                      "Fundamentals and Governance")))

conflictmerged <- fastDummies::dummy_cols(conflictmerged, select_columns = "sensitivity", remove_first_dummy = FALSE)

################################### DISTCAP ####################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m1_1 <- lmer(productivity ~ distcap * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 2: Sensitivity - Engineering Disciplines
m1_2 <- lmer(productivity ~ distcap * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 3: Sensitivity - Environmental and Safety Standards
m1_3 <- lmer(productivity ~ distcap * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 4: Sensitivity - Fundamentals and Governance
m1_4 <- lmer(productivity ~ distcap * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 5: Sensitivity - Health and Medical Technology
m1_5 <- lmer(productivity ~ distcap * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 6: Sensitivity - Manufacturing and Production
m1_6 <- lmer(productivity ~ distcap * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 7: Sensitivity - Military Standards
m1_7 <- lmer(productivity ~ distcap * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 8: Sensitivity - Other
m1_8 <- lmer(productivity ~ distcap * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 9: Sensitivity - Scientific and Technical Standards
m1_9 <- lmer(productivity ~ distcap * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + distcap | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE)

# Model 10: Sensitivity - Transportation and Structural Engineering
m1_10 <- lmer(productivity ~ distcap * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + distcap | committee), 
              data = conflictmerged %>% 
                filter(year <= 2020) %>%
                mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE)

conflictmerged_scaled_1 <- conflictmerged %>% 
  select(productivity, distcap, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2020) %>%
  mutate(distcap = scale(distcap, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 


############################# PTAs ###################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m2_1 <- lmer(productivity ~ percent_pta * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 2: Sensitivity - Engineering Disciplines
m2_2 <- lmer(productivity ~ percent_pta * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m2_3 <- lmer(productivity ~ percent_pta * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m2_4 <- lmer(productivity ~ percent_pta * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 5: Sensitivity - Health and Medical Technology
m2_5 <- lmer(productivity ~ percent_pta * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m2_6 <- lmer(productivity ~ percent_pta * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 7: Sensitivity - Military Standards
m2_7 <- lmer(productivity ~ percent_pta * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 8: Sensitivity - Other
m2_8 <- lmer(productivity ~ percent_pta * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m2_9 <- lmer(productivity ~ percent_pta * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + percent_pta | committee), 
             data = conflictmerged %>% 
               filter(year <= 2020) %>%
               mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m2_10 <- lmer(productivity ~ percent_pta * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + percent_pta | committee), 
              data = conflictmerged %>% 
                filter(year <= 2020) %>%
                mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_2 <- conflictmerged %>% 
  select(productivity, percent_pta, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2020) %>%
  mutate(percent_pta = scale(percent_pta, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 


################################### TRADE ####################################


# Model 1: Sensitivity - Domestic and Commercial Standards
m3_1 <- lmer(productivity ~ trade * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m3_2 <- lmer(productivity ~ trade * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m3_3 <- lmer(productivity ~ trade * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m3_4 <- lmer(productivity ~ trade * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m3_5 <- lmer(productivity ~ trade * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m3_6 <- lmer(productivity ~ trade * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 7: Sensitivity - Military Standards
m3_7 <- lmer(productivity ~ trade * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 8: Sensitivity - Other
m3_8 <- lmer(productivity ~ trade * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m3_9 <- lmer(productivity ~ trade * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + trade | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m3_10 <- lmer(productivity ~ trade * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + trade | committee), 
              data = conflictmerged %>% 
                filter(year <= 2021) %>%
                mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_3 <- conflictmerged %>% 
  select(productivity, total_trade, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2021) %>%
  mutate(trade = scale(total_trade, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 

################################### TARIFF ####################################


# Model 1: Sensitivity - Domestic and Commercial Standards
m4_1 <- lmer(productivity ~ tariff * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m4_2 <- lmer(productivity ~ tariff * `sensitivity_Engineering Disciplines` +
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m4_3 <- lmer(productivity ~ tariff * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m4_4 <- lmer(productivity ~ tariff * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m4_5 <- lmer(productivity ~ tariff * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m4_6 <- lmer(productivity ~ tariff * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 7: Sensitivity - Military Standards
m4_7 <- lmer(productivity ~ tariff * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 8: Sensitivity - Other
m4_8 <- lmer(productivity ~ tariff * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m4_9 <- lmer(productivity ~ tariff * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + tariff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10 Sensitivity - Transportation and Structural Engineering
m4_10 <- lmer(productivity ~ tariff * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + tariff | committee), 
              data = conflictmerged %>% 
                filter(year <= 2021) %>%
                mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_4 <- conflictmerged %>% 
  select(productivity, total_tariff, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2021) %>%
  mutate(tariff = scale(total_tariff, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 


################################### REGIME DISTANCE ####################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m5_1 <- lmer(productivity ~ ideological_diff * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               ( + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m5_2 <- lmer(productivity ~ ideological_diff * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m5_3 <- lmer(productivity ~ ideological_diff * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 4: Sensitivity - Fundamentals and Governance
m5_4 <- lmer(productivity ~ ideological_diff * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m5_5 <- lmer(productivity ~ ideological_diff * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m5_6 <- lmer(productivity ~ ideological_diff * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 7: Sensitivity - Military Standards
m5_7 <- lmer(productivity ~ ideological_diff * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 8: Sensitivity - Other
m5_8 <- lmer(productivity ~ ideological_diff * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m5_9 <- lmer(productivity ~ ideological_diff * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + ideological_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m5_10 <- lmer(productivity ~ ideological_diff * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + ideological_diff | committee), 
              data = conflictmerged %>% 
                filter(year <= 2021) %>%
                mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = FALSE) 

conflictmerged_scaled_5 <- conflictmerged %>% 
  select(productivity, ideological_diff, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2021) %>%
  mutate(ideological_diff = scale(ideological_diff, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 

################################### UN DIFF ####################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m6_1 <- lmer(productivity ~ un_diff * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m6_2 <- lmer(productivity ~ un_diff * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m6_3 <- lmer(productivity ~ un_diff * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m6_4 <- lmer(productivity ~ un_diff * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m6_5 <- lmer(productivity ~ un_diff * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m6_6 <- lmer(productivity ~ un_diff * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# # Model 7: Sensitivity - Military Standards
# m6_7 <- lmer(productivity ~ un_diff * `sensitivity_Military Standards` + 
#                factor(year) +
#                edition + re +
#                (1 + un_diff | committee), 
#              data = conflictmerged %>% 
#                filter(year <= 2014) %>%
#                mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
#                       re = scale(re, scale = TRUE, center = TRUE),
#                       edition = scale(edition, scale = TRUE, center = TRUE),
#                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
#              REML = TRUE) 

# Model 8: Sensitivity - Other
m6_8 <- lmer(productivity ~ un_diff * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m6_9 <- lmer(productivity ~ un_diff * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + un_diff | committee), 
             data = conflictmerged %>% 
               filter(year <= 2014) %>%
               mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m6_10 <- lmer(productivity ~ un_diff * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + un_diff | committee), 
              data = conflictmerged %>% 
                filter(year <= 2014) %>%
                mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_6 <- conflictmerged %>% 
  select(productivity, un_diff, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2014) %>%
  mutate(un_diff = scale(un_diff, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 


################################### UNGA DIFF ####################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m7_1 <- lmer(productivity ~ unga_speech * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 2: Sensitivity - Engineering Disciplines
m7_2 <- lmer(productivity ~ unga_speech * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m7_3 <- lmer(productivity ~ unga_speech * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 4: Sensitivity - Fundamentals and Governance
m7_4 <- lmer(productivity ~ unga_speech * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 5: Sensitivity - Health and Medical Technology
m7_5 <- lmer(productivity ~ unga_speech * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 6: Sensitivity - Manufacturing and Production
m7_6 <- lmer(productivity ~ unga_speech * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 7: Sensitivity - Military Standards
m7_7 <- lmer(productivity ~ unga_speech * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 8: Sensitivity - Other
m7_8 <- lmer(productivity ~ unga_speech * `sensitivity_Other` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m7_9 <- lmer(productivity ~ unga_speech * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re +
               (1 + unga_speech | committee), 
             data = conflictmerged %>% 
               filter(year <= 2021) %>%
               mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = FALSE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m7_10 <- lmer(productivity ~ unga_speech * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re +
                (1 + unga_speech | committee), 
              data = conflictmerged %>% 
                filter(year <= 2021) %>%
                mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = FALSE) 

conflictmerged_scaled_7 <- conflictmerged %>% 
  select(productivity, unga_speech, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2021) %>%
  mutate(unga_speech = scale(unga_speech, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 

################################### RIVALRY ####################################


# Model 1: Sensitivity - Domestic and Commercial Standards
m8_1 <- lmer(productivity ~ percent_rivalry * `sensitivity_Domestic and Commercial Standards` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m8_2 <- lmer(productivity ~ percent_rivalry * `sensitivity_Engineering Disciplines` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m8_3 <- lmer(productivity ~ percent_rivalry * `sensitivity_Environmental and Safety Standards` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m8_4 <- lmer(productivity ~ percent_rivalry * `sensitivity_Fundamentals and Governance` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m8_5 <- lmer(productivity ~ percent_rivalry * `sensitivity_Health and Medical Technology` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m8_6 <- lmer(productivity ~ percent_rivalry * `sensitivity_Manufacturing and Production` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# # Model 7: Sensitivity - Military Standards
# m8_7 <- lmer(productivity ~ percent_rivalry * `sensitivity_Military Standards` +
#                factor(year) +
#                edition + re + 
#                (1 + percent_rivalry | committee), 
#              data = conflictmerged %>% 
#                filter(year <= 2010) %>%
#                mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
#                       re = scale(re, scale = TRUE, center = TRUE),
#                       edition = scale(edition, scale = TRUE, center = TRUE),
#                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
#              REML = TRUE) 

# Model 8: Sensitivity - Other
m8_8 <- lmer(productivity ~ percent_rivalry * `sensitivity_Other` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m8_9 <- lmer(productivity ~ percent_rivalry * `sensitivity_Scientific and Technical Standards` +
               factor(year) +
               edition + re + 
               (1 + percent_rivalry | committee), 
             data = conflictmerged %>% 
               filter(year <= 2010) %>%
               mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m8_10 <- lmer(productivity ~ percent_rivalry * `sensitivity_Transportation and Structural Engineering` +
                factor(year) +
                edition + re + 
                (1 + percent_rivalry | committee), 
              data = conflictmerged %>% 
                filter(year <= 2010) %>%
                mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_8 <- conflictmerged %>% 
  select(productivity, percent_rivalry, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2010) %>%
  mutate(percent_rivalry = scale(percent_rivalry, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 

################################### ALLIANCE ####################################

# Model 1: Sensitivity - Domestic and Commercial Standards
m9_1 <- lmer(productivity ~ percent_alliance * `sensitivity_Domestic and Commercial Standards` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 2: Sensitivity - Engineering Disciplines
m9_2 <- lmer(productivity ~ percent_alliance * `sensitivity_Engineering Disciplines` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 3: Sensitivity - Environmental and Safety Standards
m9_3 <- lmer(productivity ~ percent_alliance * `sensitivity_Environmental and Safety Standards` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 4: Sensitivity - Fundamentals and Governance
m9_4 <- lmer(productivity ~ percent_alliance * `sensitivity_Fundamentals and Governance` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 5: Sensitivity - Health and Medical Technology
m9_5 <- lmer(productivity ~ percent_alliance * `sensitivity_Health and Medical Technology` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 6: Sensitivity - Manufacturing and Production
m9_6 <- lmer(productivity ~ percent_alliance * `sensitivity_Manufacturing and Production` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 7: Sensitivity - Military Standards
m9_7 <- lmer(productivity ~ percent_alliance * `sensitivity_Military Standards` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 8: Sensitivity - Other
m9_8 <- lmer(productivity ~ percent_alliance * `sensitivity_Other` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 9: Sensitivity - Scientific and Technical Standards
m9_9 <- lmer(productivity ~ percent_alliance * `sensitivity_Scientific and Technical Standards` + 
               factor(year) +
               edition + re + 
               (1 + percent_alliance | committee), 
             data = conflictmerged %>% 
               filter(year <= 2018) %>%
               mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                      re = scale(re, scale = TRUE, center = TRUE),
                      edition = scale(edition, scale = TRUE, center = TRUE),
                      productivity = scale(productivity, scale = TRUE, center = TRUE)),
             REML = TRUE) 

# Model 10: Sensitivity - Transportation and Structural Engineering
m9_10 <- lmer(productivity ~ percent_alliance * `sensitivity_Transportation and Structural Engineering` + 
                factor(year) +
                edition + re + 
                (1 + percent_alliance | committee), 
              data = conflictmerged %>% 
                filter(year <= 2018) %>%
                mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
                       re = scale(re, scale = TRUE, center = TRUE),
                       edition = scale(edition, scale = TRUE, center = TRUE),
                       productivity = scale(productivity, scale = TRUE, center = TRUE)),
              REML = TRUE) 

conflictmerged_scaled_9 <- conflictmerged %>% 
  select(productivity, percent_alliance, edition, status, ics_number_main, 
         `sensitivity_Domestic and Commercial Standards`, `sensitivity_Engineering Disciplines`, `sensitivity_Environmental and Safety Standards`,
         `sensitivity_Fundamentals and Governance`, `sensitivity_Health and Medical Technology`, `sensitivity_Manufacturing and Production`,
         `sensitivity_Military Standards`, sensitivity_Other, `sensitivity_Scientific and Technical Standards`, `sensitivity_Transportation and Structural Engineering`,
         re, year, committee, standards) %>%
  filter(year <= 2018) %>%
  mutate(percent_alliance = scale(percent_alliance, scale = TRUE, center = TRUE),
         re = scale(re, scale = TRUE, center = TRUE),
         edition = scale(edition, scale = TRUE, center = TRUE),
         productivity = scale(productivity, scale = TRUE, center = TRUE)) %>%
  drop_na() 



#################### COEF PLOT #############################

fig1 <- broom.mixed::tidy(m1_1) %>%
  filter(term == "distcap:`sensitivity_Domestic and Commercial Standards`") %>%
  bind_rows(broom.mixed::tidy(m1_2) %>%
              filter(term == "distcap:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m1_3) %>%
              filter(term == "distcap:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m1_4) %>%
              filter(term == "distcap:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m1_5) %>%
              filter(term == "distcap:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m1_6) %>%
              filter(term == "distcap:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m1_7) %>%
              filter(term == "distcap:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m1_8) %>%
              filter(term == "distcap:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m1_9) %>%
              filter(term == "distcap:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m1_10) %>%
              filter(term == "distcap:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m2_1) %>%
              filter(term == "percent_pta:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m2_2) %>%
              filter(term == "percent_pta:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m2_3) %>%
              filter(term == "percent_pta:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m2_4) %>%
              filter(term == "percent_pta:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m2_5) %>%
              filter(term == "percent_pta:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m2_6) %>%
              filter(term == "percent_pta:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m2_7) %>%
              filter(term == "percent_pta:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m2_8) %>%
              filter(term == "percent_pta:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m2_9) %>%
              filter(term == "percent_pta:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m2_10) %>%
              filter(term == "percent_pta:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m3_1) %>%
              filter(term == "trade:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m3_2) %>%
              filter(term == "trade:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m3_3) %>%
              filter(term == "trade:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m3_4) %>%
              filter(term == "trade:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m3_5) %>%
              filter(term == "trade:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m3_6) %>%
              filter(term == "trade:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m3_7) %>%
              filter(term == "trade:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m3_8) %>%
              filter(term == "trade:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m3_9) %>%
              filter(term == "trade:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m3_10) %>%
              filter(term == "trade:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m4_1) %>%
              filter(term == "tariff:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m4_2) %>%
              filter(term == "tariff:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m4_3) %>%
              filter(term == "tariff:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m4_4) %>%
              filter(term == "tariff:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m4_5) %>%
              filter(term == "tariff:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m4_6) %>%
              filter(term == "tariff:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m4_7) %>%
              filter(term == "tariff:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m4_8) %>%
              filter(term == "tariff:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m4_9) %>%
              filter(term == "tariff:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m4_10) %>%
              filter(term == "tariff:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m5_1) %>%
              filter(term == "ideological_diff:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m5_2) %>%
              filter(term == "ideological_diff:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m5_3) %>%
              filter(term == "ideological_diff:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m5_4) %>%
              filter(term == "ideological_diff:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m5_5) %>%
              filter(term == "ideological_diff:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m5_6) %>%
              filter(term == "ideological_diff:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m5_7) %>%
              filter(term == "ideological_diff:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m5_8) %>%
              filter(term == "ideological_diff:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m5_9) %>%
              filter(term == "ideological_diff:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m5_10) %>%
              filter(term == "ideological_diff:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m6_1) %>%
              filter(term == "un_diff:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m6_2) %>%
              filter(term == "un_diff:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m6_3) %>%
              filter(term == "un_diff:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m6_4) %>%
              filter(term == "un_diff:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m6_5) %>%
              filter(term == "un_diff:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m6_6) %>%
              filter(term == "un_diff:`sensitivity_Manufacturing and Production`")) %>%
  # bind_rows(broom.mixed::tidy(m6_7) %>%
  #             filter(term == "un_diff:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m6_8) %>%
              filter(term == "un_diff:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m6_9) %>%
              filter(term == "un_diff:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m6_10) %>%
              filter(term == "un_diff:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m7_1) %>%
              filter(term == "unga_speech:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m7_2) %>%
              filter(term == "unga_speech:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m7_3) %>%
              filter(term == "unga_speech:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m7_4) %>%
              filter(term == "unga_speech:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m7_5) %>%
              filter(term == "unga_speech:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m7_6) %>%
              filter(term == "unga_speech:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m7_7) %>%
              filter(term == "unga_speech:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m7_8) %>%
              filter(term == "unga_speech:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m7_9) %>%
              filter(term == "unga_speech:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m7_10) %>%
              filter(term == "unga_speech:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  bind_rows(broom.mixed::tidy(m8_1) %>%
              filter(term == "percent_rivalry:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m8_2) %>%
              filter(term == "percent_rivalry:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m8_3) %>%
              filter(term == "percent_rivalry:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m8_4) %>%
              filter(term == "percent_rivalry:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m8_5) %>%
              filter(term == "percent_rivalry:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m8_6) %>%
              filter(term == "percent_rivalry:`sensitivity_Manufacturing and Production`")) %>%
  # bind_rows(broom.mixed::tidy(m8_7) %>%
  #             filter(term == "percent_rivalry:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m8_8) %>%
              filter(term == "percent_rivalry:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m8_9) %>%
              filter(term == "percent_rivalry:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m8_10) %>%
              filter(term == "percent_rivalry:`sensitivity_Transportation and Structural Engineering`")) %>%
  
  
  bind_rows(broom.mixed::tidy(m9_1) %>%
              filter(term == "percent_alliance:`sensitivity_Domestic and Commercial Standards`")) %>%
  bind_rows(broom.mixed::tidy(m9_2) %>%
              filter(term == "percent_alliance:`sensitivity_Engineering Disciplines`")) %>%
  bind_rows(broom.mixed::tidy(m9_3) %>%
              filter(term == "percent_alliance:`sensitivity_Environmental and Safety Standards`")) %>%
  bind_rows(broom.mixed::tidy(m9_4) %>%
              filter(term == "percent_alliance:`sensitivity_Fundamentals and Governance`")) %>%
  bind_rows(broom.mixed::tidy(m9_5) %>%
              filter(term == "percent_alliance:`sensitivity_Health and Medical Technology`")) %>%
  bind_rows(broom.mixed::tidy(m9_6) %>%
              filter(term == "percent_alliance:`sensitivity_Manufacturing and Production`")) %>%
  bind_rows(broom.mixed::tidy(m9_7) %>%
              filter(term == "percent_alliance:`sensitivity_Military Standards`")) %>%
  bind_rows(broom.mixed::tidy(m9_8) %>%
              filter(term == "percent_alliance:sensitivity_Other")) %>%
  bind_rows(broom.mixed::tidy(m9_9) %>%
              filter(term == "percent_alliance:`sensitivity_Scientific and Technical Standards`")) %>%
  bind_rows(broom.mixed::tidy(m9_10) %>%
              filter(term == "percent_alliance:`sensitivity_Transportation and Structural Engineering`")) 

fig1 <- fig1 %>%
  
  mutate(conf.low = c(
    # Model 1: Distcap with Sensitivity Variables
    conf_int(m1_1, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m1_2, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m1_3, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m1_4, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m1_5, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m1_6, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m1_7, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Military Standards`")[[5]],
    conf_int(m1_8, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:sensitivity_Other")[[5]],
    conf_int(m1_9, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m1_10, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 2: Percent PTA with Sensitivity Variables
    conf_int(m2_1, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m2_2, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m2_3, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m2_4, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m2_5, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m2_6, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m2_7, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Military Standards`")[[5]],
    conf_int(m2_8, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:sensitivity_Other")[[5]],
    conf_int(m2_9, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m2_10, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 3: Trade with Sensitivity Variables
    conf_int(m3_1, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m3_2, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m3_3, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m3_4, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m3_5, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m3_6, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m3_7, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Military Standards`")[[5]],
    conf_int(m3_8, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:sensitivity_Other")[[5]],
    conf_int(m3_9, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m3_10, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 4: Tariff with Sensitivity Variables
    conf_int(m4_1, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m4_2, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m4_3, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m4_4, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m4_5, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m4_6, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m4_7, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Military Standards`")[[5]],
    conf_int(m4_8, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:sensitivity_Other")[[5]],
    conf_int(m4_9, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m4_10, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 5: Ideological Diff with Sensitivity Variables
    conf_int(m5_1, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m5_2, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m5_3, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m5_4, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m5_5, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m5_6, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m5_7, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Military Standards`")[[5]],
    conf_int(m5_8, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:sensitivity_Other")[[5]],
    conf_int(m5_9, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m5_10, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 6: Un Diff with Sensitivity Variables
    conf_int(m6_1, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m6_2, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m6_3, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m6_4, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m6_5, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m6_6, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Manufacturing and Production`")[[5]],
    #conf_int(m6_7, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Military Standards`")[[5]],
    conf_int(m6_8, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:sensitivity_Other")[[5]],
    conf_int(m6_9, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m6_10, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 7: UNGA Speech with Sensitivity Variables
    conf_int(m7_1, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m7_2, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m7_3, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m7_4, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m7_5, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m7_6, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m7_7, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Military Standards`")[[5]],
    conf_int(m7_8, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:sensitivity_Other")[[5]],
    conf_int(m7_9, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m7_10, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 8: Percent Rivalry with Sensitivity Variables
    conf_int(m8_1, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m8_2, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m8_3, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m8_4, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m8_5, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m8_6, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Manufacturing and Production`")[[5]],
    #conf_int(m8_7, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Military Standards`")[[5]],
    conf_int(m8_8, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:sensitivity_Other")[[5]],
    conf_int(m8_9, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m8_10, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Transportation and Structural Engineering`")[[5]],
    
    # Model 9: Percent Alliance with Sensitivity Variables
    conf_int(m9_1, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Domestic and Commercial Standards`")[[5]],
    conf_int(m9_2, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Engineering Disciplines`")[[5]],
    conf_int(m9_3, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Environmental and Safety Standards`")[[5]],
    conf_int(m9_4, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Fundamentals and Governance`")[[5]],
    conf_int(m9_5, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Health and Medical Technology`")[[5]],
    conf_int(m9_6, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Manufacturing and Production`")[[5]],
    conf_int(m9_7, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Military Standards`")[[5]],
    conf_int(m9_8, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:sensitivity_Other")[[5]],
    conf_int(m9_9, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Scientific and Technical Standards`")[[5]],
    conf_int(m9_10, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Transportation and Structural Engineering`")[[5]]
  ))


fig1 <- fig1 %>%
  mutate(conf.high = c(
           
         # Model 1: Distcap with Sensitivity Variables
         conf_int(m1_1, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m1_2, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m1_3, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m1_4, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m1_5, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m1_6, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m1_7, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Military Standards`")[[6]],
         conf_int(m1_8, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:sensitivity_Other")[[6]],
         conf_int(m1_9, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m1_10, vcov = "CR0", cluster = conflictmerged_scaled_1$committee, coefs = "distcap:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 2: Percent PTA with Sensitivity Variables
         conf_int(m2_1, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m2_2, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m2_3, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m2_4, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m2_5, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m2_6, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m2_7, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Military Standards`")[[6]],
         conf_int(m2_8, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:sensitivity_Other")[[6]],
         conf_int(m2_9, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m2_10, vcov = "CR0", cluster = conflictmerged_scaled_2$committee, coefs = "percent_pta:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 3: Trade with Sensitivity Variables
         conf_int(m3_1, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m3_2, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m3_3, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m3_4, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m3_5, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m3_6, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m3_7, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Military Standards`")[[6]],
         conf_int(m3_8, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:sensitivity_Other")[[6]],
         conf_int(m3_9, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m3_10, vcov = "CR0", cluster = conflictmerged_scaled_3$committee, coefs = "trade:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 4: Tariff with Sensitivity Variables
         conf_int(m4_1, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m4_2, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m4_3, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m4_4, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m4_5, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m4_6, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m4_7, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Military Standards`")[[6]],
         conf_int(m4_8, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:sensitivity_Other")[[6]],
         conf_int(m4_9, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m4_10, vcov = "CR0", cluster = conflictmerged_scaled_4$committee, coefs = "tariff:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 5: Ideological Diff with Sensitivity Variables
         conf_int(m5_1, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m5_2, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m5_3, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m5_4, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m5_5, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m5_6, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m5_7, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Military Standards`")[[6]],
         conf_int(m5_8, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:sensitivity_Other")[[6]],
         conf_int(m5_9, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m5_10, vcov = "CR0", cluster = conflictmerged_scaled_5$committee, coefs = "ideological_diff:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 6: Un Diff with Sensitivity Variables
         conf_int(m6_1, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m6_2, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m6_3, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m6_4, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m6_5, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m6_6, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Manufacturing and Production`")[[6]],
         #conf_int(m6_7, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Military Standards`")[[6]],
         conf_int(m6_8, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:sensitivity_Other")[[6]],
         conf_int(m6_9, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m6_10, vcov = "CR0", cluster = conflictmerged_scaled_6$committee, coefs = "un_diff:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 7: UNGA Speech with Sensitivity Variables
         conf_int(m7_1, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m7_2, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m7_3, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m7_4, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m7_5, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m7_6, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m7_7, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Military Standards`")[[6]],
         conf_int(m7_8, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:sensitivity_Other")[[6]],
         conf_int(m7_9, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m7_10, vcov = "CR0", cluster = conflictmerged_scaled_7$committee, coefs = "unga_speech:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 8: Percent Rivalry with Sensitivity Variables
         conf_int(m8_1, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m8_2, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m8_3, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m8_4, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m8_5, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m8_6, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Manufacturing and Production`")[[6]],
         #conf_int(m8_7, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Military Standards`")[[6]],
         conf_int(m8_8, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:sensitivity_Other")[[6]],
         conf_int(m8_9, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m8_10, vcov = "CR0", cluster = conflictmerged_scaled_8$committee, coefs = "percent_rivalry:`sensitivity_Transportation and Structural Engineering`")[[6]],
         
         # Model 9: Percent Alliance with Sensitivity Variables
         conf_int(m9_1, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Domestic and Commercial Standards`")[[6]],
         conf_int(m9_2, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Engineering Disciplines`")[[6]],
         conf_int(m9_3, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Environmental and Safety Standards`")[[6]],
         conf_int(m9_4, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Fundamentals and Governance`")[[6]],
         conf_int(m9_5, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Health and Medical Technology`")[[6]],
         conf_int(m9_6, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Manufacturing and Production`")[[6]],
         conf_int(m9_7, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Military Standards`")[[6]],
         conf_int(m9_8, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:sensitivity_Other")[[6]],
         conf_int(m9_9, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Scientific and Technical Standards`")[[6]],
         conf_int(m9_10, vcov = "CR0", cluster = conflictmerged_scaled_9$committee, coefs = "percent_alliance:`sensitivity_Transportation and Structural Engineering`")[[6]]
  ))

figure <- fig1 %>%
  mutate(group = ifelse(str_detect(term, "ideological_diff"), "Average regime distance",
                        ifelse(str_detect(term, "unga_speech"), "Average UNGA mentions",
                               ifelse(str_detect(term, "percent_rivalry"), "Share strategic rivals",
                                      ifelse(str_detect(term, "percent_alliance"), "Share defensive alliances",
                                             ifelse(str_detect(term, "un_diff"), "Average UN voting distance",
                                                    ifelse(str_detect(term, "percent_pta"), "Share PTAs",
                                                           ifelse(str_detect(term, "trade"), "Average bilateral trade",
                                                                  ifelse(str_detect(term, "tariff"), "Average bilateral tariffs",
                                                                         ifelse(str_detect(term, "distcap"), "Average geography distance",
                                                                                "none")))))))))) 

p1 <- figure %>%
  filter(group %in% c("Share PTAs", "Average bilateral trade", "Average bilateral tariffs", "Average geography distance")) %>%
  mutate(term = str_replace_all(term, ".*_", "")) %>%
  mutate(term = str_replace_all(term, "`", "")) %>%
  mutate(term = str_squish(term)) %>%
  ggplot(aes(term, estimate, label = group)) + 
  geom_point(size = 1) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), colour = "gray", linewidth = 0.5) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  labs(x = "", y = "")  + 
  facet_wrap(~group, scales ="free", nrow = 3) +
  coord_flip() +
  theme_bw() +
  theme(axis.text =element_text(size=rel(1.2)),
        strip.text.x = element_text(size = 13))

p2 <- figure %>%
  filter(group %in% c("Average regime distance", "Average UN voting distance", "Average UNGA mentions", "Share strategic rivals", "Share defensive alliances")) %>%
  mutate(term = str_replace_all(term, ".*_", "")) %>%
  mutate(term = str_replace_all(term, "`", "")) %>%
  mutate(term = str_squish(term)) %>%
  ggplot(aes(term, estimate, label = group)) + 
  geom_point(size = 1) + 
  geom_errorbar(aes(ymin = conf.low, ymax = conf.high), colour = "gray", linewidth = 0.5) + 
  geom_hline(yintercept = 0, linetype = "dashed") +
  labs(x = "", y = "Committee producitvity")  + 
  facet_wrap(~group, scales ="free", nrow = 3) +
  coord_flip() +
  theme_bw() +
  theme(axis.text =element_text(size=rel(1.2)),
        strip.text.x = element_text(size = 13))

p1 / p2 +
  patchwork::plot_layout(
    guides = "collect",
    nrow = 2,
    heights = c(.8, 1.2)  # Equal height for both rows
  ) +
  patchwork::plot_annotation() &
  theme(legend.position = "bottom", legend.direction = "horizontal")
